package com.lykj.llw.box.custom.imageload

import android.app.Activity
import android.net.Uri
import android.widget.ImageView
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.lykj.lib_base.component.GlideApp
import com.lzy.imagepicker.loader.ImageLoader

/**
 * ================================================
 * 设置glide加载器
 * ================================================
 *
 * @author gosha
 * @date 2022/10/10-13:42
 */
class GlideImageLoader : ImageLoader {
    override fun displayImage(
        activity: Activity?,
        uri: Uri?,
        imageView: ImageView?,
        width: Int,
        height: Int
    ) {
        GlideApp.with(activity!!) //配置上下文
            .load(uri) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
//            .error(R.drawable.ic_default_image) //设置错误图片
//            .placeholder(R.drawable.ic_default_image) //设置占位图片
            .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存全尺寸
            .transition(DrawableTransitionOptions.withCrossFade())
            .into(imageView!!)
    }

    override fun clearMemoryCache() {

    }
}